/**
 * @file msg_queue.h
 * @author TimeChicken (https://gitee.com/Time--Chicken)
 * @brief 消息队列管理服务，采用面向对象 思想 编写
 * @version 0.1
 * @date 2021-08-23
 * 
 * @copyright Copyright (c) 2021
 * 
 */
#ifndef __MSG_QUEUE_H__
#define __MSG_QUEUE_H__

#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>

// #include <linux/input.h>
// #include <linux/fb.h>
#include <sys/ioctl.h>
#include <stdbool.h>
#include <strings.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>

#include <sys/types.h>
#include <sys/shm.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <semaphore.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "breathing.h"

//#include "breathing.h"

typedef struct msg_queue_node
{
    data_packet *data;
    struct msg_queue_node *next;
} msg_queue_node;

typedef struct msg_queue_manage
{
    int msg_count; //消息队列数量
    msg_queue_node *head;
    msg_queue_node *tail;
} msg_queue_manage;

extern msg_queue_manage msg_queue_manager;

void msg_manage_init(void);
msg_queue_node *msg_manage_out();                              //出队
int msg_manage_in(msg_queue_node *node);                       //入队
data_packet *msgQueueNode_to_dataPacket(msg_queue_node *node); //数据包转消息节点
msg_queue_node *dataPacket_to_msgQueueNode(data_packet *d_p);  //消息节点转数据包
data_packet *msgQueue_out_dataPacket();                        //出队直接返回出队的数据包
int msgQueue_in_dataPacket(data_packet *d_p);                  //传入数据包直接入队
void msg_manage_uninit(void);                                  //释放消息队列，但也有可能不释放

#endif /* __MSG_QUEUE_H__ */